package com.jack.thinking.java._22.swing.html;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

import com.utils.SwingConsole;

public class HTMLButton extends JFrame{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final String HTML_BUTTON = "<html><b><font size=+2><center>Hello!<br><i>Press me now !";
	public static final String HTML_LABEL  = "<html><i><font size=+4>Kapow!";
	private JButton b = new JButton(HTML_BUTTON);
	public HTMLButton() {
		b.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				add(new JLabel(HTML_LABEL));
				validate();           //这个标签不是在构造器中增加的，所以必须调用容器的validate()强制 对组件进行重新布局。
			}
		});
		setLayout(new FlowLayout());
		add(b);
	}
	
	public static void main(String[] args) {
		SwingConsole.run(new HTMLButton(), 200, 500);
	}
}
